#!/bin/sh
# This regression test is a part of SIPp.
# Each scenario's <init> runs once: the out-of-call scenario's its own,
# not the main scenario's a second time.
. "`dirname "$0"`/../functions"; init

sippbg -sn uas -i 127.0.0.1 -p 5070 -m 1
sippfg -sf uac.xml -oocsf ooc.xml -i 127.0.0.1 -p 5071 -m 1 127.0.0.1:5070 \
    -trace_logs -log_file init.log -timeout 6 -timeout_error >/dev/null 2>&1
status=$?
main=`grep -c '^main init$' init.log`
ooc=`grep -c '^ooc init$' init.log`
rm -f init.log

if test $status -ne 0; then
    fail "UAC failed with $status"
elif test "$main $ooc" != "1 1"; then
    fail "main init ran $main times, the out-of-call one $ooc times"
else
    ok
fi
